package com.ly.web.controller.erp;

import java.util.List;

import com.ly.heart.service.IDeptPropertyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.DeptPropertyEntity;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 部门属性Controller
 *
 * @author cxl
 * @date 2024-06-30
 */
@Api(value = "部门属性", tags = "部门属性")
@RestController
@RequestMapping("/heart/DeptProperty")
public class DeptPropertyController extends BaseController {

    @Resource
    private IDeptPropertyService deptPropertyService;

    /**
     * 查询部门属性列表
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:list')")
    @GetMapping("/list")
    @ApiOperation("查询部门属性列表")
    public TableDataInfo list(DeptPropertyEntity deptPropertyEntity)
    {
        startPage();
        List<DeptPropertyEntity> list = deptPropertyService.selectDeptPropertyEntityList(deptPropertyEntity);
        return getDataTable(list);
    }

    /**
     * 导出部门属性列表
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:export')")
    @Log(title = "部门属性", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出部门属性列表")
    public AjaxResult export(DeptPropertyEntity deptPropertyEntity)
    {
        List<DeptPropertyEntity> list = deptPropertyService.selectDeptPropertyEntityList(deptPropertyEntity);
        ExcelUtil<DeptPropertyEntity> util = new ExcelUtil<DeptPropertyEntity>(DeptPropertyEntity.class);
        return util.exportExcel(list, "DeptProperty");
    }

    /**
     * 获取部门属性详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取部门属性详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(deptPropertyService.selectDeptPropertyEntityById(id));
    }

    /**
     * 新增部门属性
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:add')")
    @Log(title = "部门属性", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增部门属性")
    public AjaxResult add(@RequestBody DeptPropertyEntity deptPropertyEntity)
    {
        return toAjax(deptPropertyService.insertDeptPropertyEntity(deptPropertyEntity));
    }

    /**
     * 修改部门属性
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:edit')")
    @Log(title = "部门属性", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改部门属性")
    public AjaxResult edit(@RequestBody DeptPropertyEntity deptPropertyEntity)
    {
        return toAjax(deptPropertyService.updateDeptPropertyEntity(deptPropertyEntity));
    }

    /**
     * 删除部门属性
     */
    @PreAuthorize("@ss.hasPermi('heart:DeptProperty:remove')")
    @Log(title = "部门属性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除部门属性")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deptPropertyService.deleteDeptPropertyEntityByIds(ids));
    }
}
